﻿@model RTW.OA.Areas.Personal.Models.AddressViewModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}

<div class="content" style="min-width: 800px;height: 100%;width: 100%;">
    <div class="row" style="margin:0px;">
        <div class=" grouplist col-md-2">
            <div class="bts">
                <a href="#new_add" id="new_add2" type="button" role="button" style="width:80px;height:35px;" onclick="parent.createTab('0501','新建通讯录','@Url.Action("AddressEdit","Address",new { area="Personal"})')" class="btn btn-success" data-toggle="modal"><i class="icon-plus icon-white"></i>新建</a>
                <input name="" href="#edit_add" type="hidden" value="编辑" role="button" class="bt" id="edit" data-toggle="modal">
                <div class="btn-group">
                    <button hidefocus="true" type="submit" class="btn btn-info dropdown-toggle" style="width:80px;height:35px;" data-toggle="dropdown">更多<span class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li>
                            <a id="group_manage2" href="#group_manage" role="button" onclick="parent.createTab('0502','分组管理','@Url.Action("AddressGroup","Address",new { area="Personal"})')">分组管理</a>
                        </li>
                        <li>
                            <a id="import_info2" href="#import_info" role="button" data-toggle="modal">导入数据</a>
                        </li>
                        <li>
                            <a id="export_info2" href="#export_info" role="button" data-toggle="modal">导出数据</a>
                        </li>
                    </ul>
                </div>

            </div>
            <div style="height:500px;overflow-y:auto;overflow-x:hidden;">
                <dl>
                    <dt class="grouphead"><span><i class="iconfont icon-user" style="color:forestgreen;"></i></span>我的分组</dt>
                    <dd style="margin-left:0px;">
                        <ul class="groupul">
                            <li onclick="show_group('','')"><span>默认组</span></li>
                            @if (Model.AddressGroupLists != null && Model.AddressGroupLists.Any())
                            {
                                foreach (var item in Model.AddressGroupLists)
                                {
                                    <li onclick="show_group('@item.GROUP_ID', '@item.USER_ID')" title="@item.GROUP_NAME"><span>@item.GROUP_NAME</span></li>
                                }
                            }
                        </ul>
                    </dd>
                </dl>
            </div>
        </div>

        <div class="addresslist col-md-3">
            <div class="input-group stylish-input-group" style="margin:10px 5px;">
                <input type="text" class="form-control" placeholder="搜索联系人" id="queryKey" value="" />
                <span class="input-group-addon">
                    <span class="iconfont icon-sousuo" onclick="query_Address();"></span>
                </span>
            </div>

            <div id="div_AddressList_Content" style="height:500px;overflow-y:auto;overflow-x:hidden;"></div>
        </div>

        <div id="div_Details_Content"></div>
    </div>

</div>

@section scripts{
    <script src="@Url.Content("~/Content/JS/common/WdatePicker/WdatePicker.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/jquery/Validform_v5.3.2_min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/artdialog/dialog-plus-min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/webuploader/webuploader.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.config.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.all.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/lang/zh-cn/zh-cn.js")"></script>
    <script src="@Url.Content("~/Content/JS/common/from.js")"></script>

    <script type="text/javascript">
        $(function () {
            show_group("", "");
        });

        function show_group(groupId, userId) {
            $("#div_AddressList_Content").empty();
            $("#div_Details_Content").empty();
            var keyWord = "";
            $("#queryKey").val("");
            $.ajax({
                type: "POST",
                traditional: true,
                url: '@Url.Action("GroupList", "Address", new { area = "Personal" })',
                async: true,
                data: { "groupId": groupId, "userId": userId, "keyWord": keyWord },
                success: function (data) {
                    $("#div_AddressList_Content").html(data);
                },
                error: function () {

                }
            });
            show_add("", groupId);
        }

        function show_add(addId, groupId) {
            var keyWord = $("#queryKey").val();
            if (keyWord == null || keyWord == "undefined") {
                keyWord = "";
            }
            $.ajax({
                type: "POST",
                traditional: true,
                url: '@Url.Action("Details", "Address", new { area = "Personal" })',
                async: true,
                data: { "id": addId, "groupId": groupId, "keyWord": keyWord },
                success: function (data) {
                    $("#div_Details_Content").html(data);
                },
                error: function () {

                }
            });
        }

        function query_Address() {
            debugger
            var keyWord = $("#queryKey").val();
            var groupId = $("#Address_Group_GROUP_ID").val();
            var userId = "";
            if (keyWord != null && keyWord != "") {
                $("#div_AddressList_Content").empty();
                $("#div_Details_Content").empty();
                $.ajax({
                    type: "POST",
                    traditional: true,
                    url: '@Url.Action("GroupList", "Address", new { area = "Personal" })',
                    async: true,
                        data: { "groupId": groupId, "userId": userId, "keyWord": keyWord },
                    success: function (data) {
                        $("#div_AddressList_Content").html(data);
                    },
                    error: function () {

                    }
                });
                show_add("", groupId);
            }
            show_group(groupId, "");
        }
    </script>
}

